package jf.collections.range;

import java.util.Iterator;
import java.util.NoSuchElementException;

/**
 * @author ivanalx
 * @date 01.06.2009 14:45:44
 */
public class IntegerRangeIterator implements Iterator<Integer> {
	private int stop;
	private int step;
	private int current;

	public IntegerRangeIterator(int start, int stop, int step) {
		this.stop = stop;
		this.step = step;
		current = start;
	}

	@Override
	public boolean hasNext() {
		return current <= stop; 
	}

	@Override
	public Integer next() {
		if (current > stop) {
			throw new NoSuchElementException();
		}
		int tmp = current;
		current += step;
		return tmp;
	}

	@Override
	public void remove() {
		throw new UnsupportedOperationException();
	}
}
